package org.cytoscape.myapp.cytoscape_app_v1.internal.tasks.metrics;

import org.cytoscape.model.CyNetwork;
import org.cytoscape.myapp.cytoscape_app_v1.internal.helpers.ModelUtils;
import org.cytoscape.myapp.cytoscape_app_v1.internal.metrics.Facade;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskMonitor;

public class CalculateSocialCentralityTask implements Task{

	private Facade facade;
	private CyNetwork cyNetwork;
	
	public CalculateSocialCentralityTask(Facade facade,
			CyNetwork cyNetwork) {

		this.facade = facade;
		this.cyNetwork = cyNetwork;

	}

	@Override
	public void run(TaskMonitor taskMonitor) throws Exception {
		
		taskMonitor.setTitle("Eliminando Grupos");
		taskMonitor.setStatusMessage("Iniciando");
		
		double[] sc = this.facade.getCentrality();
		
		ModelUtils.updateTableNode("Social Centrality", sc, this.facade.getMapping(), this.cyNetwork);
		
		taskMonitor.setStatusMessage("Finalizando");
	}

	@Override
	public void cancel() {
		// TODO Auto-generated method stub
		
	}

}
